/ Assembly List / LJCNetCommon / HTMLBuilder / GetLine

Namespace - LJCNetCommon


Parameters
text - The text value.
addIndent - Indicates if the element can be indented.
allowNewLine - Indicates if a new line can be added.

Returns

The potentially indented and wrapped new text value.

Syntax

C#
public String GetLine(String text = null, Boolean addIndent = True, Boolean allowNewLine = True)

Gets a modified text line.

Remarks

GetLine() is a "GetString" method. It creates and returns the potentially indented and wrapped text. It will start the returned text with a new line if the builder already has text.
It appends a new line to the returned text. The applied indent is the product of the class properties IndentCount and IndentCharCount. (IndentCount * IndentCharCount).
The "addIndent" parameter defaults to true. Set it to false to prevent indenting the line further.
The "allowNewLine" parameter defaults to true. Set it to false to prevent starting with a new line.
Wraps the text with a newline if the WrapEnabled parameter is true and the line length is greater than LineLimit.
GetLine() works the same as GetText() except it appends a new line.

Example

C#
// Defaults: IndentCharCount = 2, LineLimit = 80, WrapEnabled = false.
var hb = new HTMLBuilder();

hb.AddText("This is an appended line.");

// The builder keeps track of the current number of indents.
hb.AddIndent();

// Example Method:
// Starts the text with a newline if the builder already has text
// and param allowNewLine = true and builder text does not end with
// a newline.
// The text begins with the current indent string if param
// addIndent = true.
// Ends the text with a newline.
// Defaults: addIndent = true, allowNewLine = true.
var text = hb.GetLine();
hb.AddText(text);

hb.Text(":");
var result = hb.ToString();

// result:
// This is an appended line.
//
// :

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.